/**
 * 
 * @class NG.response.Response
 * @extends Ext.util.Observable
 */
NG.response.Response = Ext.extend(Ext.util.Observable, {

	/**
	 * Any instance of class extended from NG.command.Request
	 * @cfg command
	 */
	command:null,
	
	exception: null,
	exceptionCode: null,
	
	constructor: function(config){
		config = config || {};
		NG.response.Response.superclass.constructor.call(this, config);
		this.init(config.xmlData);
	},
	
	/**
	 * Parses given xmlData (response data) <br>
	 * Fulfills related response object's members according to parsed xml data
	 * 
	 * @param {String} xmlData - response data
	 * Called by {@link NG.response.Response.constructor}
	 */
	init: function (xmlData) {
		if (Ext.isEmpty(xmlData)) {
			throw "XML Data boş, null veya undefined";
		}		
		var xmlStr = fleegix.xml.parse(fleegix.xml.createDoc(xmlData), 'string').string;
		var exception = fleegix.xml.parse(fleegix.xml.createDoc(xmlStr), "ServiceException");
		if (!Ext.isEmpty(exception)) {
			this.exception = exception.ServiceException;
		}
	},
	
	hasException: function () {
		return !Ext.isEmpty(this.exception);
	},
	
	/**
	 * The command property must be set in <b>getResponse</b> function of the commands.
	 * @return {NG.command.Request} command of the response
	 */
	getCommand: function (){
		return this.command;
	}
	
});